﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HAILN_Y2016CS32ONLINE.Structure_Program.Exer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btndangnhap_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if(string.IsNullOrEmpty(txtTenTruyNhap.Text)){
                MessageBox.Show("De nghi ban nhap vao");
                //errorProvider1.SetError(txtTenTruyNhap, "De nghi ban nhap vao");
                txtTenTruyNhap.Focus();
            }
            else if (string.IsNullOrEmpty(txtMatKhau.Text))
            {
                MessageBox.Show("De nghi ban nhap vao");
                //errorProvider1.SetError(txtMatKhau, "De nghi ban nhap vao");
                txtMatKhau.Focus();
            }
            else
            {
                if (txtTenTruyNhap.Text.Equals("abc")
                    && txtMatKhau.Text.Equals("nothing"))
                {
                    frmMain frm = new frmMain();
                    frm.ShowDialog();
                }
                else
                    //MessageBox.Show("");
                  
                txtMatKhau.Text = "";
                txtTenTruyNhap.Text = "";

            }
        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            DialogResult yes = MessageBox.Show("ban co chac chan muon thoat ung dung hong","thong bao",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
            if (yes == System.Windows.Forms.DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void login_keypress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (Char)Keys.Enter)
            {
                btndangnhap_Click(sender, e);
            }

          //  if (!Char.IsNumber(e.KeyChar) && e.KeyChar != (Char)Keys.Back && e.KeyChar != (Char)Keys.Delete)
        //    {
         //       errorProvider1.SetError(txtTenTruyNhap, "hay nhap xxx");
          //      e.Handled=true;
           // }
        }
    }
}
